package cn.top.system.controller;

import cn.top.model.AjaxResult;
import cn.top.system.entity.User;
import cn.top.system.service.ILoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/system")
public class LoginController {

    @Autowired
    private ILoginService loginService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody User user) throws Exception {
        return loginService.login(user);
    }

    @GetMapping("/logout")
    public AjaxResult logout(){
        return loginService.logout();
    }

    @GetMapping("/test")
    @PreAuthorize("hasAuthority('system:user:list')")
    public String test(){
        return "hello";
    }
}
